[id].vue 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641
  1. <template>
  2. <!-- 页面头部 -->
  3. <HomePageHead></HomePageHead>
  4. <!-- 导航栏 -->
  5. <HomePageNavigation></HomePageNavigation>
  6. <!-- 面包屑导航 -->
  7. <div class="breadcrumb">
  8. <div class="inner">
  9. <span class="location">当前位置:</span>
  10. <el-breadcrumb :separator-icon="ArrowRight">
  11. <el-breadcrumb-item>
  12. <NuxtLink to="/">首页</NuxtLink>
  13. </el-breadcrumb-item>
  14. <el-breadcrumb-item v-if="parent_children_count > 0">
  15. <NuxtLink :to="`/${parent_pinyin}/index.html`"> {{ parent_name }}</NuxtLink>
  16. </el-breadcrumb-item>
  17. <el-breadcrumb-item v-if="parent_children_count == 0">
  18. <NuxtLink :to="`/${parent_pinyin}/list-1.html`"> {{ parent_name }}</NuxtLink>
  19. </el-breadcrumb-item>
  20. <el-breadcrumb-item class="phone_breadcrumb_text" v-if="!routeNewsTtitle">{{ routeNewsTtitle }}</el-breadcrumb-item>
  21. </el-breadcrumb>
  22. </div>
  23. </div>
  24. <!-- 资讯列表 -->
  25. <div class="newsDetail">
  26. <div class="inner">
  27. <div class="innerLeft">
  28. <div class="LeftTop">
  29. <h1>{{ newsDetail.title }}</h1>
  30. <p class="phone_none">
  31. 发布时间: <span>{{ time }}</span>
  32. 来源: <span>{{ newsDetail.copyfrom }}</span>
  33. 作者: <span>{{ newsDetail.author }}</span>
  34. </p>
  35. </div>
  36. <div class="leftBottom" v-html="newsDetail.content" v-if="newsDetail.content" @click="openPreview">
  37. </div>
  38. <div v-if="previewVisible" class="preview-modal" @click="closePreview">
  39. <img :src="selectedImage" alt="Preview">
  40. </div>
  41. <!-- 免责声明: -->
  42. <div class="disclaimer" v-if="newsDetail.copyfrom != '本网'">
  43. <p>原文链接:{{ newsDetail.fromurl }}</p>
  44. <p>[免责声明]本文来源于网络转载,仅供学习交流使用,不构成商业目的。 版权归原作者所有,如涉及作品内容,版权和其他问题,请在30日与本网联系,我们将第一时间处理。</p>
  45. </div>
  46. <!-- 投票 start ---------------------------------------->
  47. <!-- <div v-if="articleChoice">
  48. <div class="index_3_box_vote" v-if="articleChoice">
  49. <div class="voteTitle">投票区</div>
  50. <div class="inquire">
  51. <p v-if="voteList.length > 0">{{ voteList[0].survey_name }}</p>
  52. <div class="radioBox">
  53. 投票选项
  54. <div v-if="!isDisabled">
  55. <div class="radio" v-if="isRadio">
  56. <el-radio-group v-model="radio1" @change="handleRadioChange">
  57. <el-radio v-for="item in voteList" :key="item.id" :value="item.id"
  58. size="large">
  59. <span v-if="item.is_other == 0">{{ item.choice_name }}</span>
  60. <span v-else>其他</span>
  61. </el-radio>
  62. </el-radio-group>
  63. <el-input v-if="showUserChoice" v-model="userChoice" :rows="2" type="textarea"
  64. resize="none" placeholder="请输入.." />
  65. </div>
  66. <div class="checkInputBox" v-else>
  67. <el-checkbox-group v-model="check1" @change="handleCheckboxChange">
  68. <span v-for="item in voteList" :key="item.id">
  69. <span v-if="item.is_other == 0">
  70. <el-checkbox size="large" :label="item.choice_name"
  71. :value="item.id" />
  72. </span>
  73. <span v-else>
  74. <el-checkbox size="large" label="其他" :value="item.id" />
  75. </span>
  76. </span>
  77. </el-checkbox-group>
  78. <el-input v-if="showUserChoice" v-model="userChoice" :rows="2" type="textarea"
  79. resize="none" placeholder="请输入.." />
  80. </div>
  81. </div>
  82. 投票结果
  83. <div class="inquireData" v-else>
  84. <div v-for="item in websiteSurveyData.data" :key="item.id">
  85. <div class="inquireDataItem active" v-if="item.status == 1">
  86. <div class="inquireDataItemTitle">
  87. <span v-if="item.choice_name == ''">其他</span>
  88. <span v-else>{{ item.choice_name }}</span>
  89. </div>
  90. <div class="inquireDataItemNum">{{ item.results }}票</div>
  91. </div>
  92. <div class="inquireDataItem" v-else>
  93. <div class="inquireDataItemTitle">
  94. <span v-if="item.choice_name == ''">其他</span>
  95. <span v-else>{{ item.choice_name }}</span>
  96. </div>
  97. <div class="inquireDataItemNum">{{ item.results }}票</div>
  98. </div>
  99. </div>
  100. </div>
  101. </div>
  102. <div class="btn">
  103. <button class="voting" @click="addWebsiteSurvey" :disabled="isDisabled"
  104. v-if="!isDisabled">投票</button>
  105. </div>
  106. </div>
  107. </div>
  108. </div> -->
  109. <!-- 投票 end ---------------------------------------->
  110. <!-- <div class="recommendRead" v-if="newsDetail.commendArticle != false">
  111. <div class="recommendReadTitle">
  112. <span class="read_title">
  113. 推荐阅读
  114. </span>
  115. </div>
  116. <div class="recommendReadList">
  117. <div class="recommendReadListTitle" v-for="(item, index) in newsDetail.commendArticle"
  118. :key="item.id">
  119. <a :href="`/${item.alias_pinyin}/${item.id}.html`" v-if="index < 3">
  120. {{ item.title }}
  121. </a>
  122. </div>
  123. </div>
  124. </div> -->
  125. </div>
  126. <div class="innerRight">
  127. <!-- 热点资讯1 -->
  128. <div class="hotList1">
  129. <DetailHotNews></DetailHotNews>
  130. </div>
  131. <!-- 热点资讯2 -->
  132. <div class="hotList2">
  133. <DetailHotNews2></DetailHotNews2>
  134. </div>
  135. </div>
  136. </div>
  137. </div>
  138. <!-- 页面底部 -->
  139. <HomeFoot></HomeFoot>
  140. </template>
  141. <script setup>
  142. //1.页面依赖 start ---------------------------------------->
  143. import { onMounted } from 'vue'
  144. import { ElBreadcrumb, ElBreadcrumbItem, ElRadio, ElRadioGroup, ElCheckbox, ElCheckboxGroup, ElMessage, ElInput } from 'element-plus'
  145. import { ArrowRight } from '@element-plus/icons-vue'
  146. const nuxtApp = useNuxtApp();
  147. const axios = nuxtApp.$axios;
  148. //1.1 获得跳转过来的id
  149. const route = useRoute();
  150. //获得详情id
  151. const articleId = parseInt(route.params.id); //获得该页面的id
  152. //获得当前的完整路径
  153. const fullPath = route.path;
  154. //拆分,取出来中间这一段,然后提取数字部分
  155. const segments = fullPath.split('/');
  156. const targetSegment = segments[1];
  157. // const numberPart = targetSegment.match(/\d+$/)?.[0];
  158. // let routeId = 20 //排除路径错误可以打开这个
  159. // const routeId = numberPart;
  160. let routeId;
  161. //通过导航路径反向查询导航id
  162. const getRouteId = await requestDataPromise('/web/getWebsiteRoute', {
  163. method: 'GET',
  164. query: {
  165. 'pinyin': targetSegment,
  166. },
  167. });
  168. if (getRouteId.code == 200) {
  169. routeId = getRouteId.data.category_id
  170. } else {
  171. console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
  172. console.log("错误位置:通过url路径查询导航池id")
  173. console.log("后端错误反馈:", getRouteId.message)
  174. console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
  175. }
  176. //1.2 获得父级栏目的名称、id
  177. const parent_name = ref([]);
  178. const parent_id = ref([]);
  179. const parent_pinyin = ref("");
  180. const parent_children_count = ref(0)
  181. let getParentNav = async () => {
  182. const listData = await requestDataPromise('/web/getOneWebsiteCategory', {
  183. method: 'GET',
  184. query: {
  185. 'catid': routeId
  186. },
  187. });
  188. console.log("获取父级栏目数据")
  189. console.log(listData)
  190. if (listData.code == 200) {
  191. console.log(listData.data);
  192. parent_name.value = listData.data.alias;
  193. parent_id.value = listData.data.parent_id;
  194. parent_pinyin.value = listData.data.aLIas_pinyin;
  195. parent_children_count.value = listData.data.children_count;
  196. } else {
  197. console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
  198. console.log("错误位置:获取面包屑导航")
  199. console.log("后端错误反馈:", listData.message)
  200. console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
  201. }
  202. }
  203. //获得父级栏目详情
  204. getParentNav();
  205. //1.页面依赖 end ---------------------------------------->
  206. //2.页面数据 start ---------------------------------------->
  207. //2.1 资讯详情
  208. const newsDetail = ref({})
  209. const routeNewsTtitle = ref("");
  210. //2.2 发布日期
  211. const time = ref("");
  212. //2.3 路径
  213. const routLevelTitle = ref("");
  214. const routLevelId = ref("");
  215. //是否展示投票
  216. const articleChoice = ref(false);
  217. //2.4获取详情
  218. async function getPageData() {
  219. const mkdata = await requestDataPromise('/web/selectWebsiteArticleInfo', {
  220. method: 'GET',
  221. query: {
  222. 'articleid': articleId
  223. },
  224. });
  225. if (mkdata.code == 200) {
  226. //判断是否显示投票
  227. if (mkdata.data.is_survey == 1) {
  228. console.log("本篇文章含有投票!")
  229. articleChoice.value = true;
  230. getVoteList();
  231. }
  232. //获取内容
  233. newsDetail.value = mkdata.data;
  234. //获取路径
  235. routLevelTitle.value = newsDetail.value.cat_name;
  236. routLevelId.value = newsDetail.value.category_id;
  237. //获取发布时间
  238. time.value = newsDetail.value.updated_at.split(' ')[0];
  239. //修正标题长度
  240. if (newsDetail.value.title.length >= 30) {
  241. routeNewsTtitle.value = newsDetail.value.title.substr(0, 30) + "...";
  242. } else {
  243. routeNewsTtitle.value = newsDetail.value.title
  244. }
  245. } else {
  246. console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
  247. console.log("错误位置:获取详情内容")
  248. console.log("后端错误反馈:", mkdata.message)
  249. console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
  250. }
  251. }
  252. getPageData();
  253. //2.5 获得广告
  254. //广告列表
  255. let adImg1 = ref([]);
  256. // async function getAdData(){
  257. // const adData = await requestDataPromise('/web/getWebsiteAdvertisement',{method:'GET',query:{'ad_tag':'DETAIL'}});
  258. // if(adData.code==200){
  259. // for(let item of adData.data){
  260. // if(item.ad_tag == 'DETAIL_0001'){
  261. // adImg1.value = item;
  262. // }
  263. // }
  264. // }else{
  265. // console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
  266. // console.log("错误位置:获取详情页广告列表")
  267. // console.log("后端错误反馈:",adData.message)
  268. // console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
  269. // }
  270. // }
  271. // getAdData();
  272. onMounted(async () => {
  273. const { $webUrl, $CwebUrl } = useNuxtApp();
  274. //广告1
  275. let url = `${$webUrl}/web/getWebsiteAdvertisement?ad_tag=snzxw_detail_0001`
  276. const responseAd1 = await fetch(url, {
  277. headers: {
  278. 'Content-Type': 'application/json',
  279. 'Userurl': $CwebUrl,
  280. 'Origin': $CwebUrl
  281. }
  282. });
  283. const resultAd1 = await responseAd1.json();
  284. adImg1.value = resultAd1.data[0];
  285. })
  286. //2.页面数据 end ---------------------------------------->
  287. //3.设置seo信息 start---------------------------------------->
  288. //3.1 设置seo信息
  289. const setData = await requestDataPromise('/web/selectWebsiteArticleInfo', {
  290. method: 'GET',
  291. query: {
  292. 'articleid': articleId
  293. },
  294. });
  295. if (setData.code == 200) {
  296. let seoTitle = setData.data.title;
  297. let seoDescription = setData.data.introduce;
  298. let seoKeywords = setData.data.keyword;
  299. let seoSuffix = setData.data.suffix;
  300. let seoName = setData.data.website_name;
  301. useSeoMeta({
  302. title: seoTitle + "_" + seoName + "_" + seoSuffix,
  303. meta: [
  304. { name: 'description', content: seoDescription + "_" + seoName + "_" + seoSuffix, tagPriority: 10 },
  305. { name: 'keywords', content: seoKeywords + "_" + seoName + "_" + seoSuffix, tagPriority: 10 }
  306. ]
  307. });
  308. } else {
  309. console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
  310. console.log("错误位置:设置详情页面SEO数据")
  311. console.log("后端错误反馈:", setData.message)
  312. console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
  313. }
  314. //3.设置seo信息 end---------------------------------------->
  315. //4.投票 start---------------------------------------->
  316. const radio1 = ref(''); //单选
  317. const check1 = ref([]); //多选
  318. const isDisabled = ref(false);//是否禁用提交按钮
  319. const isRadio = ref(true);//是否渲染单选
  320. const userSurId = ref('');//投票属于哪一篇文章
  321. const userChoice = ref('');//用于判断用户选择了其他选项以后,输入的值
  322. const userIsChoice = ref('');//用于判断其他选项目前是什么值
  323. const showUserChoice = ref(false);//是否显示其他输入框
  324. const websiteSurveyData = ref([]);//投票结果
  325. //3.2获得投票列表
  326. let voteList = ref([]);
  327. async function getVoteList() {
  328. const voteData = await requestHome('/web/getWebsiteSurvey', { method: 'GET', query: { 'art_id': articleId } });
  329. console.log(778899)
  330. console.log(voteData)
  331. if (voteData.code == 200) {
  332. voteList.value = voteData.data;
  333. console.log(voteList.value)
  334. //判断显示单选还是多选
  335. //survey_type 0是单选 1是多选
  336. if (voteData.data[0].survey_type == 0) {
  337. isRadio.value = true;
  338. console.log("1111")
  339. } else {
  340. isRadio.value = false;
  341. }
  342. //把最后一个的值拿出来 用于判断用户是否选择了其他
  343. for (let item of voteData.data) {
  344. //如果含有其他
  345. if (item.is_other == 1) {
  346. userIsChoice.value = item.id;
  347. }
  348. }
  349. //用户投票属于哪一篇文章
  350. userSurId.value = voteData.data[0].sur_id;
  351. } else {
  352. console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
  353. console.log("错误位置:首页投票")
  354. console.log("后端错误反馈:", voteData.message)
  355. console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
  356. }
  357. }
  358. //3.2当用户选择了选项,判断是否展示其他输入框
  359. const handleRadioChange = (value) => {
  360. if (value == userIsChoice.value) {
  361. showUserChoice.value = true;
  362. } else {
  363. showUserChoice.value = false;
  364. }
  365. }
  366. const handleCheckboxChange = (value) => {
  367. if (value.includes(userIsChoice.value)) {
  368. showUserChoice.value = true;
  369. } else {
  370. showUserChoice.value = false;
  371. }
  372. }
  373. //3.2发起投票
  374. async function addWebsiteSurvey() {
  375. //判断当前是单选还是多选
  376. console.log(isRadio.value)
  377. if (isRadio.value) {
  378. console.log("用户单选!")
  379. if (radio1.value != '') {
  380. //先判断一下是否使用了其他选项
  381. if (showUserChoice.value) {
  382. if (userChoice.value != '') {
  383. //文章id
  384. // console.log(userSurId.value)
  385. // 用户输入的值
  386. // console.log(userChoice.value)
  387. //如果使用了其他,其他的选项需要增加进去
  388. const ChoiceData = await requestHome('/web/addWebsiteSurveyOption', {
  389. method: 'GET',
  390. query: {
  391. 'sur_id': userSurId.value,//投票的新闻id
  392. 'choice_name': userChoice.value,//投票的选项id
  393. }
  394. });
  395. if (ChoiceData.code == 200) {
  396. //提交完其他选项以后,再正式发起投票
  397. const mkData = await requestHome('/web/addWebsiteSurveyVote', {
  398. method: 'GET',
  399. query: {
  400. 'sur_id': userSurId.value,
  401. 'choice_id': ChoiceData.data
  402. }
  403. });
  404. if (mkData.code == 200) {
  405. ElMessage.success('投票成功!')
  406. //把投票结果显示到页面上 禁用投票按钮
  407. isDisabled.value = true;
  408. websiteSurveyData.value = mkData.data;
  409. //遍历一下,把用户选中的那个设置status为1
  410. let data = mkData.data;
  411. //遍历一下,把用户选中的那个设置status为1
  412. for (let item of data.data) {
  413. for (let i of data.choice) {
  414. if (item.id == i) {
  415. console.log(item.id)
  416. item.status = 1;
  417. }
  418. }
  419. }
  420. websiteSurveyData.value = data;
  421. } else {
  422. ElMessage.error(mkData.message)
  423. }
  424. } else {
  425. ElMessage.error('其他投票失败!')
  426. }
  427. } else {
  428. ElMessage.error('请输入选项内容!')
  429. }
  430. } else {
  431. //如果没选择其他,直接提交选择的内容
  432. const mkData = await requestHome('/web/addWebsiteSurveyVote', {
  433. method: 'GET',
  434. query: {
  435. 'sur_id': userSurId.value,
  436. 'choice_id': radio1.value
  437. }
  438. });
  439. if (mkData.code == 200) {
  440. ElMessage.success('投票成功!')
  441. //把投票结果显示到页面上 禁用投票按钮
  442. isDisabled.value = true;
  443. let data = mkData.data;
  444. //遍历一下,把用户选中的那个设置status为1
  445. for (let item of data.data) {
  446. for (let i of data.choice) {
  447. if (item.id == i) {
  448. item.status = 1;
  449. }
  450. }
  451. }
  452. websiteSurveyData.value = data;
  453. } else {
  454. ElMessage.error('投票失败!')
  455. }
  456. }
  457. } else {
  458. ElMessage.error('请选择一个选项')
  459. }
  460. } else {
  461. console.log("多选!")
  462. //多选
  463. if (check1.value != []) {
  464. //先判断一下是否使用了其他选项
  465. if (showUserChoice.value) {
  466. if (userChoice.value != '') {
  467. //判断用户是否只选择了一个其他
  468. if (check1.value.length == 1) {
  469. const ChoiceData = await requestDataPromise('/web/addWebsiteSurveyOption', {
  470. method: 'GET',
  471. query: {
  472. 'sur_id': userSurId.value,//投票的新闻id
  473. 'choice_name': userChoice.value,//用户输入的其他选项文字
  474. }
  475. });
  476. if (ChoiceData.code == 200) {
  477. //提交完其他选项以后,再正式发起投票
  478. const mkData = await requestDataPromise('/web/addWebsiteSurveyVote', {
  479. method: 'GET',
  480. query: {
  481. 'sur_id': userSurId.value,
  482. 'choice_id': ChoiceData.data
  483. }
  484. });
  485. if (mkData.code == 200) {
  486. ElMessage.success('投票成功!')
  487. //把投票结果显示到页面上 禁用投票按钮
  488. isDisabled.value = true;
  489. websiteSurveyData.value = mkData.data;
  490. //遍历一下,把用户选中的那个设置status为1
  491. let data = mkData.data;
  492. //遍历一下,把用户选中的那个设置status为1
  493. for (let item of data.data) {
  494. for (let i of data.choice) {
  495. if (item.id == i) {
  496. console.log(item.id)
  497. item.status = 1;
  498. }
  499. }
  500. }
  501. websiteSurveyData.value = data;
  502. } else {
  503. ElMessage.error(mkData.message)
  504. }
  505. } else {
  506. ElMessage.error('其他投票失败!')
  507. }
  508. } else {
  509. //用户选择了除了其他以外,还包括别的选项
  510. const ChoiceData = await requestDataPromise('/web/addWebsiteSurveyOption', {
  511. method: 'GET',
  512. query: {
  513. 'sur_id': userSurId.value,//投票的新闻id
  514. 'choice_name': userChoice.value,//用户输入的其他选项文字
  515. }
  516. });
  517. if (ChoiceData.code == 200) {
  518. let data = check1.value;
  519. //找到多选的数组,把其他默认值给替换掉
  520. for (let i = 0; i < data.length; i++) {
  521. if (data[i] == userIsChoice.value) {
  522. data[i] = ChoiceData.data;
  523. }
  524. }
  525. let jsonArray = JSON.stringify(data);
  526. //提交完其他选项以后,再正式发起投票
  527. const mkData = await requestDataPromise('/web/addWebsiteSurveyVote', {
  528. method: 'GET',
  529. query: {
  530. 'sur_id': userSurId.value,
  531. 'choice_id': jsonArray
  532. }
  533. });
  534. if (mkData.code == 200) {
  535. ElMessage.success('投票成功!')
  536. //把投票结果显示到页面上 禁用投票按钮
  537. isDisabled.value = true;
  538. websiteSurveyData.value = mkData.data;
  539. //遍历一下,把用户选中的那个设置status为1
  540. let data = mkData.data;
  541. //遍历一下,把用户选中的那个设置status为1
  542. for (let item of data.data) {
  543. for (let i of data.choice) {
  544. if (item.id == i) {
  545. //console.log(item.id)
  546. item.status = 1;
  547. }
  548. }
  549. }
  550. websiteSurveyData.value = data;
  551. } else {
  552. ElMessage.error(mkData.message)
  553. }
  554. } else {
  555. ElMessage.error('其他投票失败!')
  556. }
  557. }
  558. } else {
  559. ElMessage.error('请输入选项内容!')
  560. }
  561. } else {
  562. let jsonArray = JSON.stringify(check1.value);
  563. //如果没选择其他,直接提交选择的内容
  564. const mkData = await requestDataPromise('/web/addWebsiteSurveyVote', {
  565. method: 'GET',
  566. query: {
  567. 'sur_id': userSurId.value,
  568. 'choice_id': jsonArray
  569. }
  570. });
  571. if (mkData.code == 200) {
  572. ElMessage.success('投票成功!')
  573. //把投票结果显示到页面上 禁用投票按钮
  574. isDisabled.value = true;
  575. websiteSurveyData.value = mkData.data;
  576. //遍历一下,把用户选中的那个设置status为1
  577. let data = mkData.data;
  578. //遍历一下,把用户选中的那个设置status为1
  579. for (let item of data.data) {
  580. for (let i of data.choice) {
  581. if (item.id == i) {
  582. console.log(item.id)
  583. item.status = 1;
  584. }
  585. }
  586. }
  587. websiteSurveyData.value = data;
  588. } else {
  589. ElMessage.error('投票失败!')
  590. }
  591. }
  592. } else {
  593. ElMessage.error('请选择一个选项')
  594. }
  595. }
  596. }
  597. //4.投票 end---------------------------------------->
  598. //5.页面图片放大 start---------------------------------------->
  599. const previewVisible = ref(false)
  600. const selectedImage = ref(' ')
  601. const openPreview = (event) => {
  602. if (event.target.tagName === 'IMG') {
  603. selectedImage.value = event.target.src;
  604. previewVisible.value = true;
  605. }
  606. }
  607. const closePreview = () => {
  608. previewVisible.value = false;
  609. }
  610. //5.页面图片放大 end---------------------------------------->
  611. </script>
  612. <style lang="less" scoped>
  613. @import url('@/assets/css/detail.less');
  614. </style>